><

General text handling elements



Document

The Document object contains the entire document, including general properties, such as the current selection.

Clipboard
Text
R/W
This property allows for accessing the clipboard. It can be used as a function argument for the Insert Text method.
Contents
Text
R/W
The content of the document.
Length
Long
R/O
The length of the text in the document.
Font Name
Text
R/W
The name of the font used.
Font Size
Short
R/W
The size of the font used.
Font Face
Enums
R/W
The attributes of the current font. The list includes the Bold, Italic, Underline, Outline, Shadow, Condense, and Extend elements. You can omit the braces if you want to specify a single attribute only.
Tab Stops
Short
R/W
The tab stop position.
MIME Type
Text
R/O
The MIME type of the document. This function returns "text/html" by default.
Syntax Highlighting
Short
R/W
Selects Syntax Highlighting mode:
0 - off
1 - detailed
Source editor only:
2 - Links, images, and plug-ins
3 - URLs
Auto Indenting
Bool
R/W
Toggles Auto Indenting on and off.
Line Index
Long
R/W
The number of the current line.
Column Index
Long
R/W
The current column.
Current Line
Object
R/O
The current line as a line object.
Selection
Object
R/O
The current selection.
Status Line
Text
R/W
The content of the status line.

Line

The Line object refers to a specific line.

Index
Long
R/O
The line number, starting at 1.
Position
list
R/O
The Position as a list with the {line, 1} syntax.
Contents
Text
R/W
The content of the line.
Length
Long
R/O
The length of the text on the line.

Character

The Character object refers to a particular character.

Index
Long
R/O
The position of the character, relative to the beginning of the
document at position 1.
Position
list
R/O
The position as a list with the {line, column} syntax.
Contents
Text
R/W
The content of the character.
Length
Long
R/O
The length of the character (constant 1).

Selection object

The Selection object exists all the time, even if there is no current selection. The Is Visible property indicates whether the selection exists or not. You can modify the selection by changing the Starting Position and Ending Position properties. Changing the Contents property replaces the current selection with the specified text.

Address the Selection object through the Selection property, not by its name.

Starting Position
list
R/W
The beginning of the selection.
Ending Position
Long
R/W
The end of the selection.
Is Visible
Bool
R/O
True if a selection exists.
Contents
Text
R/W
The content of the selection.
Length
Long
R/O
The length of the text in the selection.

Methods

Insert Text

"Text"
Inserts the function parameter as text at the current position.
Insert File

filename
Inserts the specified file at the current cursor
position.
Find

"String"
Searches for the specified string. The result is true if the string has been found. The found string will be selected.


[Applying
Option(s)]
Applies the specified options. One or more options may be specified. Multiple options must be specified as a list in braces.

Available Options:


Ignore case

Distinguishes between uppercase and lowercase.

Wraparound

Wrap around the beginning or the end of the document.

From Top

Start the search at the beginning or the end of the text or the current selection.

Backwards

Search direction is backwards.

Word

Search word by word.
Replace
"String"

Searches for the specified string and replaces it with another string. The result is true if the string has been found and replaced. The found and replaced string will be selected.
If the direct parameter is omitted, the specified string replaces the current selection.

Using
"String"
The string used for replacing.

[Applying
Option(s)]
Applies the specified options. One or more options may be specified. Multiple options must be specified as a list in braces.

Available Options:


Ignore case

Distinguishes between uppercase and lowercase.

Wraparound

Wrap around the beginning or the end of the
document.

From Top

Start the search at the beginning or the end of the text or the current selection.

Backwards

Search direction is backwards.

Word

Search word by word.
Undo


Undoes the last changes.
Redo


Restores data to the state before the last Undo action.
Delete

Object
Deletes the specified object, which may be the selection object, a line, or other. If the object is not specified, it deletes the current selection.
Select

Object
Makes a selection. The specified object may be a suite of lines or characters--for example, "Lines 3 thru 7."

From
List
The selection may be specified using two lists with a
{line, column} syntax at the beginning and end of the
selection.

To
List
Select paragraph


This command searches a blank line before and after the
current line and selects the text between the two blank lines and the subsequent blank line, positioning the cursor on the blank line. In the example given below, the cursor is placed on the line "1st Line." The asterisks mark the lines that will be selected after executing this command.
  1st line
* 2nd line
* 3rd line
* 4th line
  etc.

[Between
Object]
As an option, the selection can be confined to
particular lines by specifying a range explicitly. Example: "Select Paragraph Between Lines 3 thru 5."
Deselect


Cancels the current selection.
Go to

Object
Sets the current position to the specified line or character object.
Delete spaces


Deletes all spaces and tabs from the current position to the end of the line or to the next character that is neither a space nor a tab.


Automating Operations Using AppleScript > General text handling elements